#include<bits/stdc++.h>
using namespace std;
int main(){
	freopen("dis.in" , "r" , stdin);
	freopen("dis.out" , "w" , stdout);
	long long a , b , ans = 0;
	cin >> a >> b;
	while(b >= 2 * a){
		if(b % 2 == 0){
			if(b == a + 1){
				b--;
				ans++;
				cout << ans << endl;
				return 0;
			}
			b = b / 2;
			ans++;
			continue;
		}
		b--;
		ans++;
	}
	cout << ans + b - a << endl;
	return 0;
}
